<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

<!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
	<script type="text/javascript" src="resources/js/jquery-1.8.3.min.js"></script>
</head>
<body>
<center>
	<h1>登陆页面</h1>
	<hr>
	<form class="form-horizontal" >
 	 <div class="form-group">
    <label for="loginname" class="col-sm-4 control-label">登录名:</label>
    <div class="col-sm-4">
      <input type="text" class="form-control" name="loginName" id="loginname" placeholder="请输入登录名……">
      <span id="p1" style="color:red"></span>
    </div>
  </div>
  
  <div class="form-group">
    <label for="password" class="col-sm-4 control-label">密&emsp;码:</label>
    <div class="col-sm-4">
      <input type="password" class="form-control" name="password" id="password" placeholder="请输入密码……" >
      <span id="p2" style="color:red"></span>
    </div>
  </div>
  
  <div class="form-group">
    <div class="col-sm-offset-3 col-sm-6">
      <div class="checkbox">
        <label>
          <input type="checkbox"> 记住密码
         
         
        </label>
         &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp; &emsp;&emsp; &emsp;&emsp; &emsp;&emsp; &emsp;
          
          <a class="text-warning" onclick="forget()">忘记密码?</a>
      </div>
    </div>
  </div>
  
  
  
  <div class="form-group">
    <div class="col-sm-offset-1 col-sm-10">
      		<button type="button" class="btn btn-primary" style="width: 500px;height: 50px"  onclick="login()">登陆</button>
    </div>
     
  </div>
  
  <div class="form-group">
    <div class="col-sm-offset-1 col-sm-7">
   		 <p > &emsp;&emsp;还没有账号?<a href="enroll" class="text-success;font-italic" >请点击注册</a></p>
    </div>
  </div>
 
</form>
</center>

<script type="text/javascript">
	function login() {
		if($('[name="loginName"]').val()==null ||$('[name="loginName"]').val()==''){
			$("#p1").html("登录名不能为空")
			return;
		}else{
			$("#p1").html("")
		}

		if($('[name="password"]').val()==null ||$('[name="password"]').val()==''){
			$("#p2").html("密码不能为空")
			return;
		}else{
			$("#p2").html("")
		}
		
		
		$.post("login",$("form").serialize(),function(resu){
			
			if(resu==3){
				alert("登录成功")
				location="list";
			}else if(resu==2){
				$("#p2").html("密码错误")
			}else{
				$("#p1").html("登录名不存在")
			}
		})
	}
	
	function forget() {
		var account=$('[name="phone"]').val()
		location="forgetPassword_1?account="+account;
	}
	
</script>
</body>
</html>